﻿using System;

namespace ShapeCalculator
{
    class Program
    {
        static void Main(string[] args)
        {
            const int numberOfShapes = 10;

            double totalArea = 0;

            // 创建10个合理的随机形状对象并计算面积之和
            for (int i = 0; i < numberOfShapes; i++)
            {
                IShape shape = ShapeFactory.CreateRandomShape();
                if (shape.IsValid())
                {
                    double area = shape.CalculateArea();
                    totalArea += area;
                    Console.WriteLine($"Shape {i + 1}: Area = {area}");
                }
                else
                {
                    i--;
                    Console.WriteLine($"形状不合理，该次计数失效");
                }
            }

            Console.WriteLine($"10个随机创建的有效对象的总面积: {totalArea}");
        }
    }
}